package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        Person person = new Person();
        person.setName("米娟");
        person.setAge(18);
        person.setGender("女");
        person.setOtherInfo(new String[]{"可爱", "好漂亮", "我喜欢"});
        System.out.println(person);
        FileOutputStream fos = new FileOutputStream("person.obj");
        //指定节点流上接入处理流 用对象处理流将对象转换为字接
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(person);
        System.out.println("对象传输完毕");
        //关闭处理流就会调用节点流的close()一层一层关闭
        oos.close();
    }
}
